//
//  ZSLVisitorTableViewController.swift
//  micro_blog
//
//  Created by Mac on 16/9/21.
//  Copyright © 2016年 Mac. All rights reserved.
//

import UIKit

class ZSLVisitorTableViewController: UITableViewController,ZSLVisitorViewDelegate
{
    
    var isLogin: Bool = false
    
    var visitorView: ZSLVisitorView?
    
    override func loadView() {
        
        if isLogin
        {
            super.loadView()
        }else
        {
            visitorView = ZSLVisitorView()
            
            visitorView?.loginClosure = {[weak self] in
                
                print("我是访客视图闭包调用过来的")
                
                self?.requestLoginOperation()
                
                
            }
            
            view = visitorView
            
            setupNavUI()
        }
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()

       
    }
    
    private func setupNavUI() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: #selector(loginAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: #selector(loginAction))
    }

    @objc private func loginAction() {
        print("你点击了登录操作")
        requestLoginOperation()
        
    }

    func didSelectedLogin() {
        print("我是访客视图代理对象调用过来的")
    }
    
    //  请求登录的操作
    private func requestLoginOperation() {
        let oAuthVC = ZSLOAuthViewController()
        let nav = ZSLNavigationController(rootViewController: oAuthVC)
        present(nav, animated: true, completion: nil)
        
    }
}
